package com.tulingxueyuan.mall.modules.pms.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tulingxueyuan.mall.common.api.CommonPage;
import com.tulingxueyuan.mall.common.api.CommonResult;
import com.tulingxueyuan.mall.modules.pms.model.PmsProductCategory;
import com.tulingxueyuan.mall.modules.pms.service.PmsProductCategoryService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 产品分类 前端控制器
 * </p>
 *
 * @author XuShu
 * @since 2022-07-06
 */
@RestController
@RequestMapping("/productCategory")
public class PmsProductCategoryController {

    /**
     *     获取商品分类接口
     *     url:'/productCategory/list/'+parentId,
     *     method:'get',
     *     params:
     *     {
     *          pageNum: number;
     *          pageSize: number;
     *     }
     * }
     */

    //获取商品分类接口
    @Autowired
    PmsProductCategoryService productCategoryService;

    @ApiOperation("获取商品分类接口")
    @RequestMapping(value = "/list/{parentId}",method = RequestMethod.GET)
    public CommonResult<CommonPage<PmsProductCategory>> getList(@PathVariable Long parentId,
                                                                @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                                                @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize){
        Page page = productCategoryService.list(parentId, pageNum, pageSize);
        return CommonResult.success(CommonPage.restPage(page));
    }

}

